package com.ztao.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.wemedia.dtos.WmMaterialDto;
import com.ztao.service.WmMaterialService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Resource
    private WmMaterialService wmMaterialService;
    @PostMapping("/upload_picture")
    public ResponseResult up(MultipartFile multipartFile){
        return  this.wmMaterialService.uploadPicture(multipartFile);
    }
    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody WmMaterialDto dto){
        return  this.wmMaterialService.list(dto);
    }

    //收藏
    @GetMapping("/collect/{id}")
    public ResponseResult collect(@PathVariable("id") Integer id){
        return  this.wmMaterialService.collect(id);
    }
    //取消收藏
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancel_collect(@PathVariable("id") Integer id){
        return  this.wmMaterialService.cancelCollect(id);
    }
    //删除
    @GetMapping("/del_picture/{id}")
    public ResponseResult delPicture(@PathVariable("id") Integer id){
        return  this.wmMaterialService.delPicture(id);
    }
}
